home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmigaPlus / Tools / Development / RxMUI / Examples / PopS.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  2004-01-31  |  4.0 KB  |  132 lines

  1. /* How to crate and handle a Popstring object */
  2.  
  3. signal on halt
  4. signal on break_c
  5.  
  6. call Init
  7. call CreateApp
  8. call HandleApp
  9. /* never reached */
  10. /***********************************************************************/
  11. Init: procedure
  12.     l="rmh.library";if ~show("L",l) then;if ~addLib(l,0,-30) then exit
  13.     if addLibrary("rxmui.library")~=0 then exit
  14.     call RxMUIOpt("DebugMode ShowErr")
  15.     return
  16. /***********************************************************************/
  17. HandleApp: procedure
  18.     ctrl_c=2**12
  19.     do forever
  20.         call NewHandle("app","h",ctrl_c)
  21.         if and(h.signals,ctrl_c)>0 then exit
  22.         select
  23.             when h.event="QUIT" then exit
  24.             otherwise interpret h.event
  25.         end
  26.     end
  27.     /* never reached */
  28. /***********************************************************************/
  29. CreateApp: procedure
  30.  
  31.     /* Application */
  32.     app.Title="PopstringExample"
  33.     app.Version="$VER: PopstringExample 2.0 (25.1.2002)"
  34.     app.Copyright="Copyright 2001-2002 by Alfonso Ranieri"
  35.     app.Author="Alfonso Ranieri"
  36.     app.Description="PopstringExample"
  37.     app.Base="RXMUIEXAMPLE"
  38.     app.SubWindow="mwin"
  39.  
  40.      /* Main window */
  41.      mwin.Title="PopstringExample"
  42.      mwin.ID="MAIN"
  43.      mwin.Contents="mgroup"
  44.  
  45.       /* Contents of mwin */
  46.       mgroup.0="g"
  47.        g.Class="group"
  48.        g.Horiz=1
  49.  
  50.         /* Popstring object */
  51.         g.0="ps"
  52.          ps.Class="popstring"
  53.          ps.Toggle=1
  54.          ps.buttoncyclechain=1
  55.  
  56.          /* As the Popstring is opening, this in-line macro is called.
  57.             It just build a list of the public ports.
  58.             Note that it returns 1 to tell the Popstring it is ok to go. */
  59.          ps.OpenFun="
  60.             call set('l','quiet',1);
  61.             pl=show('p',,'/');
  62.             do while pl~='';
  63.                 parse var pl p '/' pl;
  64.                 call domethod('l','insert',p,'sorted');
  65.             end;
  66.             call set('l','quiet',0);
  67.             return 1"
  68.  
  69.          /* As the Popstring is closed, this in-line macro is called.
  70.             It receives one argument: success. You have to tell the
  71.             Popstring what it means. If success is 1, a port was
  72.             doubleclicked, and it is set in the string. Otherwise
  73.             nothing happens. Note that it also clears the list. */
  74.          ps.CloseFun="
  75.             parse arg s;
  76.             if s then do;
  77.                 call DoMethod('l','GetEntry','active','A');
  78.                 call set('s','contents',a);
  79.             end;
  80.             call domethod('l','clear')"
  81.  
  82.          /* This is the String object */
  83.           s.CycleChain=1
  84.          ps.String=String("s")
  85.  
  86.          /* Here you should specify a Button object, but we use
  87.             the auto popup button */
  88.          /*bs.Weight=0
  89.            ps.Button=Button("BS","Pop!")*/
  90.  
  91.          /* This is the Window object */
  92.          ps.Window="pw"
  93.           pw.Class="window"
  94.           pw.Title="PopstringWindow"
  95.           pw.ID="SHOW"
  96.            pw.Contents="pwmain"
  97.             pwmain.0="lv"
  98.              lv.Class="Listview"
  99.              lv.List="l"
  100.               l.Frame="InputList"
  101.             pwmain.1=Button("cs",'_Close')
  102.  
  103.     call NewObj("APPLICATION","APP")
  104.  
  105.     /* The Window object of the Popstring must be added
  106.        to the application to be opened */
  107.     call Add("app","pw")
  108.  
  109.     /* Set lv as DefaultObject for pw */
  110.     call set("pw","DefaultObject","lv")
  111.  
  112.     call Notify("mwin","CloseRequest",1,"app","ReturnID","quit")
  113.  
  114.     /* If the Popstring-Window is closed it is a no-success event */
  115.     call Notify("pw","CloseRequest",1,"ps","Close",0)
  116.  
  117.     /* If the Close-Button is pressed it is a no-success event */
  118.     call Notify("cs","Pressed",0,"ps","Close",0)
  119.  
  120.     /* If an entry is doubleclicked it is a SUCCESS event */
  121.     call Notify("l","Doubleclick","EveryTime","ps","Close",1)
  122.  
  123.     call set("mwin","open",1)
  124.  
  125.     return
  126. /***********************************************************************/
  127. halt:
  128. break_c:
  129.     exit
  130. /**************************************************************************/
  131.  
  132.